﻿using System;
namespace Kis.Xroad.Eu {
    
    
    [System.SerializableAttribute()]
    public class DerivedSimpleUnion : global::Kis.Xroad.Eu.SimpleUnion {
        
        public DerivedSimpleUnion(global::Xtee.Core.Schema.XsdString value) : 
                base((System.String)value) {
            this.Validate();
        }
        
        public DerivedSimpleUnion(global::Xtee.Core.Schema.XsdInteger value) : 
                base((System.Decimal)value) {
            this.Validate();
        }
        
        public DerivedSimpleUnion(global::Kis.Xroad.Eu.SimpleType1 value) : 
                base((System.Decimal)value) {
            this.Validate();
        }
        
        public DerivedSimpleUnion(DateTimeType0 value) : 
                base((System.DateTime)value) {
            this.Validate();
        }
        
        public DerivedSimpleUnion() : 
                base(string.Empty) {
        }
        
        public DerivedSimpleUnion(string value) : 
                base(Parse(value).Value.ToString()) {
            this.Validate();
        }
        
        public static bool TryParse(string value, out global::Kis.Xroad.Eu.DerivedSimpleUnion result) {
            try {
                result = new global::Kis.Xroad.Eu.DerivedSimpleUnion(value);
                return true;
            }
            catch (System.Exception ) {
                result = null;
                return false;
            }
        }
        
        public static global::Kis.Xroad.Eu.DerivedSimpleUnion Parse(string value) {
            global::Xtee.Core.Schema.XsdString _XsdString = null;
            if (global::Xtee.Core.Schema.XsdString.TryParse(value,out _XsdString)) {
                return new DerivedSimpleUnion(_XsdString);
            }
            global::Xtee.Core.Schema.XsdInteger _XsdInteger = null;
            if (global::Xtee.Core.Schema.XsdInteger.TryParse(value,out _XsdInteger)) {
                return new DerivedSimpleUnion(_XsdInteger);
            }
            global::Kis.Xroad.Eu.SimpleType1 _SimpleType1 = null;
            if (global::Kis.Xroad.Eu.SimpleType1.TryParse(value,out _SimpleType1)) {
                return new DerivedSimpleUnion(_SimpleType1);
            }
            DateTimeType0 _DateTimeType0 = null;
            if (DateTimeType0.TryParse(value,out _DateTimeType0)) {
                return new DerivedSimpleUnion(_DateTimeType0);
            }
             throw new FormatException("Cannot parse to type [global::Kis.Xroad.Eu.DerivedSimpleUnion] from string value : [" + value + "]");;
        }
    }
}
